#include <iostream>
#include "SignalCtl.hpp"
#include <unistd.h>
void PrintPenging()
{
    sigset_t setpenging;
    sigpending(&setpenging);
    for(size_t i = 32;i > 0;i--)
    {
        if(i % 4 == 0){std::cout << "   ";}
        if(sigismember(&setpenging,i) == 1)
        {
            std::cout << 1;
        }
        else
        {
            std::cout << 0;
        }
        
    }
    std::cout << "\n\n";
}
void test1()
{
    sigset_t set;
    sigemptyset(&set);
    sigaddset(&set,2);

    sigprocmask(SIG_BLOCK,&set,nullptr);
    PrintPenging();
    kill(getpid(),2);
    PrintPenging();
}

void test2()
{
    SigCtl sig;
    for(int i = 1;i < 32;i++)
    {
        sig.addset(i);
    }
    sig.setblock();

    for(int i = 18;i < 19;i++)
    {
        if(i != 19)
        {
            if(raise(i))
            {
                lg(Error,"[%s-%d-raise][%s]",__FILE__,__LINE__,strerror(errno));
            }
            else
            {
                PrintPenging();
            }
            sleep(1);
        }   
    }
}


int main()
{
    test2();
    return 0;
}